/*2S7LXljdWdGhrCxZ1MFl4nbo76lbmNV/zj9vAsZ4TsJjt35I/W4VBwuu/33I9fcb*/
/*
 * @Author: xiahui 
 * @PageInfo: 采购合同维护拉价格审批单
 * @Date: 2019-04-29 13:45:50
 * @Last Modified by: zhangmi
 * @Last Modified time: 2021-09-10 12:07:29
 */
import React, { Component } from 'react';
import { createPage, base } from 'nc-lightapp-front';
import { initTemplate } from './init';
import { AREA, URL, DATASOURCECACHE, BUTTONID, FIELDS, UISTATUS, PAGECODE } from '../constance';
import { buttonClick, searchBtnClick } from './btnClicks';
import { initLang, getLangByResId } from '../../../../scmpub/scmpub/pub/tool/multiLangUtil';

const { NCToggleViewBtn, NCDiv } = base;

class PurdailyRef28 extends Component {
	constructor(props) {
		super(props);

		props.use.search(AREA.srcSearch);

		initLang(this, [ '4004purdaily' ], 'ct', initTemplate.bind(this, this.props));
	}

	componentDidMount() {
		// 刷新按钮可用
		this.props.button.setDisabled({ [BUTTONID.Refresh]: true });
		this.props.transferTable.setTransferTableValue(
			AREA.srcHead,
			AREA.srcBody,
			[],
			FIELDS.pk_priceaudit,
			FIELDS.pk_priceaudit_b
		);
	}

	render() {
		const { transferTable, search } = this.props;
		const { NCCreateSearch } = search;
		const { createTransferTable } = transferTable;
		const { createBillHeadInfo } = this.props.BillHeadInfo;
		let selectedShow = transferTable.getSelectedListDisplay(AREA.cardFormId);

		return (
			<div id="transferList" className="nc-bill-list">
				{!selectedShow ? (
					<div>
						<NCDiv areaCode={NCDiv.config.HEADER} className="nc-bill-header-area">
							<div className="header-title-search-area">
								{createBillHeadInfo({
									title: getLangByResId(this, '4004PURDAILY-000063') /* 国际化处理： 选择价格审批单*/,
									billCode: '', //单据号
									initShowBackBtn: true,
									backBtnClick: buttonClick.bind(this, this.props, BUTTONID.Back)
								})}
							</div>
							<div className="header-button-area">
								{this.props.button.createButtonApp({
									area: AREA.list_head,
									onButtonClick: buttonClick.bind(this)
								})}
							</div>
							<NCToggleViewBtn
								onClick={() => {
									if (!this.props.meta.getMeta()[AREA.srcView]) {
										initTemplate.call(this); //加载主子拉平模板
									}
									this.props.transferTable.changeViewType();
								}}
							/>
						</NCDiv>
						<div className="nc-bill-search-area" style={{ borderBottom: '1px solid #d0d0d0' }}>
							{NCCreateSearch(AREA.srcSearch, {
								clickSearchBtn: searchBtnClick.bind(this, this.props)
							})}
						</div>
					</div>
				) : (
					''
				)}

				<div className="nc-bill-transferTable-area">
					{createTransferTable({
						searchAreaCode: AREA.srcSearch,
						dataSource: DATASOURCECACHE.dataSourceRef28CacheKey,
						pkname: FIELDS.pk_priceaudit,
						headTableId: AREA.srcHead, //表格组件id
						bodyTableId: AREA.srcBody, //子表模板id
						fullTableId: AREA.srcView,
						transferBtnText: getLangByResId(this, '4004PURDAILY-000061') /* 国际化处理： 生成采购合同*/,
						containerSelector: '#transferList',
						totalKey: [ FIELDS.nordastnum ],
						totalTitle: [ getLangByResId(this, '4004PURDAILY-000062') ] /* 国际化处理： 总数量*/,
						onTransferBtnClick: () => {
							this.props.pushTo(URL.card, {
								status: UISTATUS.ref28,
								source: URL.ref28,
								pagecode: PAGECODE.cardPagecode
							});
						},
						onChangeViewClick: () => {
							//点击切换视图钩子函数
							if (!this.props.meta.getMeta()[AREA.srcView]) {
								initTemplate.call(this); //加载主子拉平模板
							}
							this.props.transferTable.changeViewType(this.headTableId);
						}
					})}
				</div>
			</div>
		);
	}
}

PurdailyRef28 = createPage({})(PurdailyRef28);

export default PurdailyRef28;

/*2S7LXljdWdGhrCxZ1MFl4nbo76lbmNV/zj9vAsZ4TsJjt35I/W4VBwuu/33I9fcb*/